
package com.onlyxiahui.common.data.common.value;

import java.util.HashMap;

import com.onlyxiahui.common.message.node.Head;

/**
 * Description <br>
 * Date 2020-05-16 13:00:19<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public class HeadValue extends HashMap<String, Object> implements Head {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 消息的id，标识消息的唯一性
	 */
	private String key;

	/**
	 * 
	 */
	@Override
	public String getKey() {
		key = this.getValue("key", String.class);
		return key;
	}

	@Override
	public void setKey(String key) {
		this.key = key;
		this.put("key", key);
	}

	@SuppressWarnings("unchecked")
	public <T> T getValue(String key, Class<T> calzz) {
		Object o = this.get(key);
		return calzz.isAssignableFrom(calzz) ? (T) o : null;
	}

}
